import request from '../utils/request';

// 简化的图片上传函数（图片编辑专用）
export const uploader = async (file, fileName) => {
    try {
        // 创建 FormData 直接上传
        const formData = new FormData();
        formData.append('file', file.fileInstance);
        formData.append('fileName', fileName || file.name);
        
        // 直接上传到图片编辑接口
        const response = await request.post('/dk/v1/fileTransfer/uploader', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
        
        // 返回上传结果
        return {
            success: true,
            url: response.data
        };
        
    } catch (error) {
        console.error('上传失败:', error);
        throw error;
    }
};